package org.reliablesource.prism.core.internal;

import java.util.ArrayList;
import java.util.List;

import org.reliablesource.prism.core.IPrismElement;
import org.reliablesource.prism.core.IPrismUpdateEvent;

/**
 *
 *  PrismUpdateEvent.java<br>
 *  Copyright (c) 2007, Reliable Source, Inc. All Rights Reserved<br><br>
 *
 *	Created on: Jun 29, 2007 <br><br>
 *  @author Dennis Park 
 *<a href="mailto:dennis.park@gmail.com">dennis.park@gmail.com</a>
 *
 * @since 1.0.0
 */
public class PrismUpdateEvent implements IPrismUpdateEvent{

	protected List <IPrismElement>changeList;
	protected int type;
	public PrismUpdateEvent (int _type){
		changeList = new ArrayList<IPrismElement>();
	}

	public boolean addToChangedList(IPrismElement _element) {
		boolean _added = false;
		if (_element != null)
			_added = changeList.add(_element);
		return _added;
	}

	public IPrismElement[] getChangedObjects() {
		return changeList.toArray(new IPrismElement[changeList.size()]);
	}

	public int getEventType() {
		return 0;
	}
	
	public boolean removeFromChangedList(IPrismElement _element) {
		boolean _removed  = false;
		if(_element != null)
			_removed =changeList.remove(_element);
		return _removed;
	}
	
	
}
